 <template>
  <!-- 详细内容页面 -->
  <div id="container">
    <el-collapse v-model="activeNames" v-loading="loading">
      <el-collapse-item title="基本信息" name="1">
        <div class="button" style="float: right">
          <el-button type="primary" @click="handleExport">导出</el-button>
        </div>
        <produce-order-detail
          ref="detail"
          :form="ProduceOrderData"
        ></produce-order-detail>
      </el-collapse-item>
      <el-collapse-item title="产品信息" name="2">
        <produce-products-detail
          ref="productsDetail"
          :id="$route.query.id"
          :source="ProduceOrderData.source"
        ></produce-products-detail>
      </el-collapse-item>
    </el-collapse>
  </div>
</template>
<script>
import produceOrderDetail from './components/produceOrderDetail.vue'
import checkProcess from '@/components/checkProcess/checkList'
import produceProductsDetail from './components/produceProductsDetail.vue'
import { queryTypeByDic } from '@/utils/getData'
import { exportFile } from "@/utils/exportFile"
export default {
  name: 'detail',
  data () {
    return {
      activeNames: ['1'],
      checkCofig: [],
      ProduceOrderData: {},
      loading: false
    }
  },
  components: {
    produceOrderDetail,
    produceProductsDetail,
    checkProcess
  },
  beforeMount () {
    this.getType()
  },
  mounted () {

  },
  methods: {
    // 获取类型
    async getType () {
      this.produceStatus = await queryTypeByDic('produceStatus')
      this.getDetail()

    },
    async getDetail () {
      this.loading = true
      let { data } = await this.$API.produce.getProduceOrderById.post({ id: this.$route.query.id })
      this.ProduceOrderData = data
      this.produceStatus.forEach(item => {
        if (item.value == this.ProduceOrderData.type) {
          this.ProduceOrderData.typeName = item.name
        }
      })
      this.activeNames.push('2')
      this.loading = false
    },
    // 导出
    async handleExport () {
      let res = await this.$API.produce.exportProduceProducts.get({ produceId: this.$route.query.id })
      exportFile(res, '生产清单.xls')
    },


  }
}
</script>
<style lang='scss' scoped>
#container {
  margin: 10px;
  :deep(.el-collapse-item__header) {
    padding-left: 20px;
    font-size: 16px;
  }
  :deep(.el-collapse-item__content) {
    padding: 0 20px 20px 20px;
  }
  :deep(.el-form-item) {
    margin-bottom: 5px;
  }
  :deep(.el-form-item__label) {
    color: #999;
  }
}
</style>